package com.aiti.lulian.controller;

import com.aiti.base.core.base.controller.WebController;
import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.service.IClusterService;
import com.aiti.lulian.vo.CardClusterInfoVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/cluster")
public class ClusterController extends WebController {

    private final IClusterService  clusterService;

    public ClusterController(IClusterService clusterService) {
        this.clusterService = clusterService;
    }

    /**
     * 查询当前用户的产业集群列表
     * @param params userId - 用户Id
     * @return 列表结果
     */
    @GetMapping("/selectCurrentClusterList")
    public Message selectCurrentClusterList(@RequestParam Map<String,String> params){
        String userId = params.get("userId");
        if(StringUtils.isBlank(userId)){
            return Message.fail("没有找到用户Id");
        }
        Page page = startPage();
        return  clusterService.selectCurrentClusterList(page,userId);
    }

    /**
     * 通过Id查询产业集群的信息
     * @param clusterId 产业集群Id
     * @return 结果
     */
    @GetMapping("/info/{clusterId}")
    public Message selectClusterInfoById(@PathVariable("clusterId") String clusterId){
        CardClusterInfoVo info =  clusterService.selectClusterInfoById(clusterId);
        return Message.success(info);
    }
}
